#pragma once

constexpr uint BINARYWRITE_BUFFER_LINE_LEN = 128;

struct Binary{
    vector<u8>      _mem;
    Binary(size_t size):_mem(size){}
    Binary(const vector<u8>& bytes):_mem(bytes){}
    Binary(vector<u8>&& bytes):_mem(std::move(bytes)){}
    Binary(string_view str):_mem(std::size(str)){
        auto p = _mem.data();
        for (size_t i = 0; i < std::size(str); i++){p[i] = (u8)str[i];}
    }
    Binary(){}
    const u8& operator[](size_t i) const{return _mem[i];}
    u8& operator[](size_t i){return _mem[i];}
    size_t size() const noexcept{return _mem.size();}
};
inline const u8* _mem(const Binary& bin) noexcept{
    return bin._mem.data();
}

struct BinaryWriter{
    using LINE = array<u8, BINARYWRITE_BUFFER_LINE_LEN>;
    using BUFFER = forward_list<LINE>;
    BUFFER _buf;
    BUFFER::iterator _curline;
    BinaryWriter():_buf(1,LINE{}),_curline(begin(_buf)){}
};
BinaryWriter& _line_add(BinaryWriter& a){
    a._curline = a._buf.emplace_after(a._curline);
    return a;
}
BinaryWriter& operator<<(BinaryWriter& out, u8 byte){
    return out;
}


